﻿using DataWorks_Sqlite.MappingClass;
using DataWorks_Tools.BasicMethods;
using DataWorks_Tools.MappModals;
using DataWorks_Tools.MergeDetails;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataWorks_Tools.ProcessExcute.Merge
{
    public class TxtMergeProcess
    {
        //txt合并总流程
        public static async Task<List<string>> TxtMergeProcessExcute(dw_props_admin dw_Props_Admin, dw_props_txtcombine dw_Props_Txtcombine)
        {
            var selectdatefilearray = dw_Props_Txtcombine.selecteddirectory.ReComma().Split(',');
            var originaldatapath = dw_Props_Txtcombine.originaldatapath.YXHPathReplace();
            var savedatapath = dw_Props_Txtcombine.savedatapath.YXHPathReplace();
            var thread = dw_Props_Admin.cleanthreadnumber;
            var ismultithreads = dw_Props_Admin.ismultithreads;
            var row = new MergeModal();
            row.odpath = originaldatapath;
            row.rdpath = savedatapath;
            row.datedir = selectdatefilearray;
            row.mergetype = mergetype.txt;
            row.threads = thread;
            if (originaldatapath != null && savedatapath != null && selectdatefilearray != null)
            {
                if (ismultithreads == 1)
                {
                    var t = await MergeDetailsMethods.YXHExcuteMergeMultiThreadAsync(row);
                    return t;
                }
                else
                {
                    var t = await MergeDetailsMethods.YXHExcuteMergeAsync(row);
                    return t;
                }
            }
            else
            {
                return new List<string>() { "参数错误" };
            }
        }
    }
}
